<?php
declare (strict_types=1);

namespace app\admin\controller\base;

use app\admin\service\base\UserService;
use app\BaseController;
use think\facade\Request;
use think\response\Json;

/**
 * 用户管理
 */
class User extends BaseController
{

    /**
     * 用户列表
     * @param UserService $userService
     * @return Json
     */
    public function userList(UserService $userService): Json
    {
        $params['page'] = Request::param('page/d', 1);
        $params['limit'] = Request::param('limit/d', 10);
        $params['openid'] = Request::param('openid/s', '');
        $params['nickname'] = Request::param('nickname/s', '');
        $params['phone'] = Request::param('phone/s', '');
        $params['subscribe'] = Request::param('subscribe/d');
        $params['sex'] = Request::param('sex/d');
        $params['start_time'] = Request::param('start_time/d', 0);
        $params['end_time'] = Request::param('end_time/d', 0);
        return $userService->userList($params);
    }

    /**
     * 取袋记录
     * @param UserService $userService
     * @return Json
     */
    public function userBagList(UserService $userService): Json
    {
        $params['page'] = Request::param('page/d', 1);
        $params['limit'] = Request::param('limit/d', 10);
        $params['mac_id'] = Request::param('mac_id/s', '');
        $params['order_no'] = Request::param('order_no/s', '');
        $params['openid'] = Request::param('openid/s', '');
        $params['order_state'] = Request::param('order_state/s', '');
        $params['start_time'] = Request::param('start_time/d', 0);
        $params['end_time'] = Request::param('end_time/d', 0);
        return $userService->userBagList($params);
    }

}
